<?php

namespace app\common\model\score;

use think\Model;


class Exchange extends Model
{

    

    

    // 表名
    protected $name = 'self_exchange_log';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'address',
        'is_process_text',
    ];
    

    
    public function getIsProcessList()
    {
        return ['0' => __('Is_process 0'), '1' => __('Is_process 1')];
    }


    public function getIsProcessTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_process']) ? $data['is_process'] : '');
        $list = $this->getIsProcessList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getUserInfoAttr($value, $data){
        $value = isset($data['user_id']) ? $data['user_id'] : 0;
        return $value ? \app\common\model\User::getBaseInfoNosense($value) : '';
    }

    public function getAddressAttr($value, $data){
        $value = isset($data['address_id']) ? $data['address_id'] : 0;
        return $value ? \app\common\model\Address::get($value) : '';
    }


    public function selfscoregoods()
    {
        return $this->belongsTo('app\common\model\score\Goods', 'score_goods_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
